package recursion;

public class Hanoi {
    public static void Hanoi(int n,String a,String b,String c){
        if (n==1) System.out.print(a+"移动到"+c+"\t");
        else {
            Hanoi(n-1,a,c,b);
            System.out.println(a+"移动到"+c+"\t");
            Hanoi(n-1,b,a,c);
        }
    }

    public static void main(String[] args) {
        System.out.println("5层的汉诺塔问题求解结果为");
        Hanoi(5,"a","b","c");
    }
}
